<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5shiv.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css" />
<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>建材列表</title>
<link rel="stylesheet" href="lib/zTree/v3/css/zTreeStyle/zTreeStyle.css" type="text/css">
</head>
<body class="pos-r">
<script th:src="@{/js/vue-2.4.0.js}"></script>
<script th:src="@{/js/vue-resource-1.3.4.js}"></script>
<div id="app">
<div class="pos-a" style="width:200px;left:0;top:0; bottom:0; height:100%; border-right:1px solid #e5e5e5; background-color:#f5f5f5; overflow:auto;">
	<div style="margin: 20px 0 10px 5px;padding-bottom: 20px; border-bottom: 1px solid lightgrey;">
		<button class="btn" onclick="beishen_add('增加','beishen-add','800','600')">增加</button>
		<button class="btn" @click="del">删除</button>
		<button class="btn" onclick="beishen_edit('编辑','beishen-edit','800','600')">编辑</button>
	</div>
	<ul id="treeDemo" class="ztree"></ul>
</div>
<div style="margin-left:200px;">
	<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 管理 <span class="c-gray en">&gt;</span> 被审计机构 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
	<div class="page-container">
		<div class="mt-20">
			<table class="table table-border table-bordered table-bg table-hover table-sort">
				<thead>
					<tr class="text-c">
						<th width="100">机构名称</th>
						<th width="100">部门开展业务</th>
						<th width="100">上次稽核时间</th>
						<th width="100">成立时间</th>
						<th width="100">财务账套</th>
						<th width="100">信用柜台编码</th>
					</tr>
				</thead>
				<tbody>
					<tr class="text-c va-m" v-for="item in UP">
						<td>{{item.department.name}}</td>
						<td>{{item.department.business}}</td>
						<td>{{item.department.audittime | dateFormat}}</td>
						<td>{{item.department.uptime | dateFormat}}</td>
						<td>{{item.department.finance}}</td>
						<td>{{item.department.coding}}</td>
					</tr>
				</tbody>
			</table>
		</div>
		<div class="mt-20" style="margin-top: 240px;">
			<table class="table table-border table-bordered table-bg table-hover table-sort">
				<thead>
					<tr class="text-c">
						<th width="100">用户名</th>
						<th width="100">姓名</th>
						<th width="100">邮箱</th>
						<th width="100">电话</th>
						<th width="100">RTX</th>
						<th width="100">状态</th>
					</tr>
				</thead>
				<tbody>
					<tr class="text-c va-m" v-for="u in userS">
						<td>{{u.name}}</td>
						<td>{{u.xname}}</td>
						<td>{{u.mailbox}}</td>
						<td>{{u.phone}}</td>
						<td>{{u.letter}}</td>
						<td>
							<span class="label label-success" v-if="u.state==0">
                             <span >正常</span>
                            </span>
							<span class="label label-error" v-if="u.state==1">
								<span >禁用</span>
                             </span>
						</td>

					</tr>
				</tbody>
			</table>
		</div>
	</div>
</div>
</div>

<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script> 
<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
<script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js"></script> 
<script type="text/javascript" src="lib/datatables/1.10.0/jquery.dataTables.min.js"></script> 
<script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript">
var setting = {
	view: {
		dblClickExpand: false,
		showLine: false,
		selectedMulti: false
	},
	data: {
		simpleData: {
			enable:true,
			idKey: "id",
			pIdKey: "pId",
			rootPId: ""
		}
	},
	callback: {
		beforeClick: function(treeId, treeNode) {
			var zTree = $.fn.zTree.getZTreeObj("tree");
			if (treeNode.isParent) {
				vm.Sel(treeNode.id,0)
/*				zTree.expandNode(treeNode);*/
				return false;
			} else {
                vm.Sel(0,treeNode.bid)
				return true;
			}
		}
	}
};

function beishen_add(title,url,w,h){
    if (vm.add!=0) {
		var url1="beishen-add?id="+vm.add
        layer_show(title, url1, w, h);
    }else {
        layer.msg("请选择部门添加机构!",{icon:7,time:1500})
	}
}	
function beishen_edit(title,url,w,h){
    if (vm.compile!=0) {
        var url="beishen-edit?id="+vm.compile
        layer_show(title, url, w, h);
    }else {
        layer.msg("请选择机构编辑!",{icon:7,time:1500})
	}
}

        $('.table-sort').dataTable({
            "bStateSave": true,//状态保存
            "aoColumnDefs": [
	  {"orderable":false,"aTargets":[0,1,2,3,4,5]},// 制定列不参与排序
	]
});


//全局过滤器
Vue.filter('dateFormat',function(dateStr,pattern){
    var dt=new Date(dateStr)
    var y=dt.getFullYear()
    var m=dt.getMonth()+1
    var d=dt.getDate()

    /*return y + '-' + m + '-' + d*/

    if (pattern && pattern.toLowerCase() === 'yyy-mm-dd') {
        return y + '-' + m + '-' + d
    } else {
        var hh= dt.getHours()
        var mm= dt.getMinutes()
        var ss= dt.getSeconds()

        return y + '-' + m + '-' + d+':'+hh+':'+mm+":"+ss
    }
})




var vm=new Vue({
    el:'#app',
    data:{
        Audit:[],
        zNodes:[],
        Department:[],
        UP:[],
		userS:[],
        add:0,
        compile:0
    },
    created() {
        this.zNodes=[{id:-1,pId:0,name:"全部",open:true}]
        this.audit_Show()
		this.department_Show()
        this.Sel(-1,0)
    },
    methods:{
        audit_Show(){
            this.$http.get("/auditDate", {
                params: {
                }
            }).then(function (result) {
                this.Audit=result.data
                for (var i=0;i<this.Audit.length;i++){
                    var car = {id:this.Audit[i].id, pId:-1, name:this.Audit[i].auditName}
                    this.zNodes.push(car)
                }
                var t = $("#treeDemo");
                t = $.fn.zTree.init(t, setting, this.zNodes);
                var zTree = $.fn.zTree.getZTreeObj("tree");
            })
		},
        department_Show(){
           this.$http.get("/DepartmentDate", {
                params: {
                }
            }).then(function (result) {
                this.Department=result.data
                for (var i=0;i<this.Department.length;i++){
                    var car = {id:this.Department[i].id+99, pId:this.Department[i].auditId, name:this.Department[i].name,bid:this.Department[i].id}
                    this.zNodes.push(car)
                }
                var t = $("#treeDemo");
                t = $.fn.zTree.init(t, setting, this.zNodes);
                var zTree = $.fn.zTree.getZTreeObj("tree");
            })
            console.log(this.zNodes)
		},
		Sel(id,bid){
            if (id!=-1){
                if (id!=0){
                    this.compile=0;
                    this.add=id
				}
			}
			if(bid!=0){
                this.add=0
                this.compile=bid;
			}

            this.userS=[]
            this.$http.get("/departmentalUsers", {
                params: {
                    id:id,
                    bid:bid
                }
            }).then(function (result) {
                this.UP=result.data
                for (var i=0;i<this.UP.length;i++){
					for (var j=0;j<this.UP[i].user.length;j++){
                        var car = {
                            name:this.UP[i].user[j].name,
							xname:this.UP[i].user[j].xname,
                            mailbox:"28"+i+"93123@136.com",
                            phone:"13"+i+"9"+i+"1"+i+"7"+i+"91",
                            letter:"A"+i,
							state:this.UP[i].user[j].state
                        }
                        this.userS.push(car)
					}
				}
            })
		},
		del(){
            if (this.compile!=0) {
                this.$http.get("/delbmpar", {
                    params: {
                        id:this.compile
                    }
                }).then(function (result) {
                    layer.msg("删除成功!",{icon:1,time:1500})
                    location.reload()
                })


            }else {
                layer.msg("请选择要删除的机构!",{icon:7,time:1500})
            }
		}
    }
})

setTimeout(function () {

},100)
</script>
</body>
</html>